package com.itheima.marking_system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.marking_system.mapper.OcrMapper;
import com.itheima.marking_system.pojo.entity.ElementEntity;
import com.itheima.marking_system.pojo.entity.OcrEntity;
import com.itheima.marking_system.service.OcrService;
import com.itheima.marking_system.utils.baidu.BaiduUtils;
import kotlin.Pair;
import org.springframework.stereotype.Service;

@Service
public class OcrServiceImpl extends ServiceImpl<OcrMapper, OcrEntity> implements OcrService {
    @Override
    public Pair<OcrEntity, String> setOcrEntity(ElementEntity elementEntity) {
        OcrEntity ocrEntity = new OcrEntity();
        ocrEntity.setData(BaiduUtils.getOcrResult(elementEntity.getData()).getBytes());
        ocrEntity.setElementId(elementEntity.getId());
        ocrEntity.setName(elementEntity.getName());
        String question = BaiduUtils.getOcrResult(elementEntity.getData())+"，请先给出答案，然后再给出解析，要求清晰易懂。";
        System.out.println(question);
        return new Pair<OcrEntity, String>  (ocrEntity,question);
    }
}
